﻿using Domain.Material_Management;
using Domain.Production_Modules;
using Infratructure.Interface;
using MediatR;
using MES.Server.API.Application.Command.Production_Modules;
using MES.Server.API.Application.Command.Production_Modules.Pulldown;
using ReturnValue;

namespace MES.Server.API.Application.Handler.Production_Modules
{
    public class GetProduceQueryCommandHandler : IRequestHandler<GetProduceQueryCommand, ApiResult<List<ProduceModel>>>
    {
        private readonly IRepository<ProduceModel> MaterialGroupRepo;
        public GetProduceQueryCommandHandler(IRepository<ProduceModel> MaterialGroupRepo)
        {
            this.MaterialGroupRepo = MaterialGroupRepo;
        }
        public Task<ApiResult<List<ProduceModel>>> Handle(GetProduceQueryCommand request, CancellationToken cancellationToken)
        {
            ApiResult<List<ProduceModel>> result = new ApiResult<List<ProduceModel>>();
            result.Code = StatusCode.Success;
            result.Message = StatusCode.Success.ToString();
            var list = MaterialGroupRepo.GetAll().Where(x=>x.Id==request.Id);
            result.Data = list.ToList();
            return Task.FromResult(result);
        }
    }
}
